﻿<UserControl x:Name="userControl" x:Class="WhatToDevelop.View.MainPanel"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:c="http://schemes.grabacr.net/winfx/2015/kancolleviewer/controls"
             xmlns:converter="clr-namespace:WhatToDevelop.Converter"
             xmlns:v="clr-namespace:WhatToDevelop.View"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="500">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/WhatToDevelop;component/Style/ListBoxStyles.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <Style TargetType="ListBox" BasedOn="{StaticResource StandardListBox}"/>
            <converter:VisibilityConverter x:Key="VisibilityConverter"/>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="24"/>
            <RowDefinition Height="24"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="1.6*"/>
        </Grid.ColumnDefinitions>
        <DockPanel Margin="10" Grid.RowSpan="3" Grid.Row="3" >
            <Border DockPanel.Dock="Bottom" Margin="0,10,0,0" Padding="3" Background="Gold" BorderBrush="DarkGoldenrod" BorderThickness="2" Visibility="{Binding HasError, Converter={StaticResource VisibilityConverter}}">
                <TextBlock Text="{Binding ErrorDescr}" Foreground="Black"/>
            </Border>
            <ListBox x:Name="listBox" DockPanel.Dock="Top" ItemsSource="{Binding List}" SelectedItem="{Binding SelectedItem}" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Path Width="10" Height="10" Stretch="Uniform" Visibility="{Binding Favorite,Converter={StaticResource BooleanToVisibilityConverter}}"
                                  Fill="Gold" StrokeThickness="1" Stroke="DarkGoldenrod" VerticalAlignment="Top" Panel.ZIndex="1"
                                  Data="F1 M 0,10.6641L 10.1434,9.19012L 14.6797,-3.05176e-005L 19.2161,9.19012L 28.6251,10.5573L 29.3595,10.6641L 22.0196,17.8204L 23.7527,27.922L 14.6797,23.1511L 5.60684,27.922L 7.3399,17.8204L 0,10.6641 Z" HorizontalAlignment="Left"/>
                            <c:SlotItemIcon Type="{Binding Icon}" Width="18" Height="18"/>
                            <TextBlock Text="{Binding Name}" Margin="5,0,0,0" Grid.Column="1"/>
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </DockPanel>
        <StackPanel Orientation="Horizontal" Grid.ColumnSpan="2">
            <TextBlock Text="显示日期" Margin="10,0" VerticalAlignment="Center"/>
            <DatePicker DockPanel.Dock="Left" Width="120" BorderBrush="Transparent" SelectedDate="{Binding Date}"/>
            <TextBlock Text="{Binding WeekCn}" VerticalAlignment="Center"/>
            <TextBlock Foreground="{DynamicResource SemiActiveForegroundBrushKey}" VerticalAlignment="Center">
                <Run>（</Run><Run Text="{Binding WeekJp, Mode=OneWay}"/><Run>）</Run>
            </TextBlock>
        </StackPanel>
        <TextBlock Text="可用的装备" Grid.Row="1" Margin="10,10,0,0"/>
        <StackPanel Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal" Margin="10,0">
            <Button Name="btnWiki" Content="Wiki页面" Click="btnWiki_Click"/>
        </StackPanel>
        <Border Grid.Column="1" Grid.Row="2" Margin="0,10,10,10" BorderBrush="{DynamicResource BorderBrushKey}" BorderThickness="1">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition MinHeight="70" Height="75*"/>
                    <RowDefinition Height="10"/>
                    <RowDefinition Height="32"/>
                    <RowDefinition Height="24"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="56"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <ListBox Grid.ColumnSpan="2" Background="Transparent" BorderThickness="0" ItemsSource="{Binding SelectedItem.Targets}" Margin="10" >
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="Auto" MinHeight="18"/>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="12"/>
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <Path Width="16" Height="16" Margin="0,0,10,0" Stroke="Gray" StrokeThickness="3.5" Stretch="Uniform"
                                      UseLayoutRounding="False" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeLineJoin="Round"
                                      Data="F1 M 328.101,80.0001L 80,328.101L 328.101,576.203"
                                      RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Top"
                                      Visibility="{Binding Enabled, Converter={StaticResource VisibilityConverter}}">
                                    <Path.RenderTransform>
                                        <ScaleTransform ScaleY="1" ScaleX="-1"/>
                                    </Path.RenderTransform>
                                </Path>
                                <TextBlock Text="{Binding Target,TargetNullValue='更新不可'}" HorizontalAlignment="Left" Grid.Column="1"/>
                                <ItemsControl Grid.Row="1" Grid.Column="1" Margin="10,0" ItemsSource="{Binding Costs}"/>
                                <TextBlock Text="{Binding No2}" DockPanel.Dock="Right" VerticalAlignment="Bottom" HorizontalAlignment="Right" Grid.Row="2" Grid.Column="1"/>
                                <v:WeekIndicator Grid.Row="3" Margin="0,5,0,0" Values="{Binding Weekdays}" Grid.ColumnSpan="3"/>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
                <Rectangle Grid.Row="1" Grid.ColumnSpan="2" Margin="10,0" Fill="{DynamicResource BorderBrushKey}" Height="1" VerticalAlignment="Top"/>
                <c:SlotItemIcon Type="{Binding SelectedItem.Icon}" Grid.RowSpan="2" Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Top" Height="46" Width="46">
                    <c:SlotItemIcon.Effect>
                        <DropShadowEffect Color="White" Opacity="0.4" BlurRadius="20" ShadowDepth="0"/>
                    </c:SlotItemIcon.Effect>
                </c:SlotItemIcon>
                <TextBlock Grid.Column="1" Grid.Row="2" Text="{Binding SelectedItem.Name}" FontSize="18" Margin="10,0" FontFamily="Meiryo UI">
                    <TextBlock.Effect>
                        <DropShadowEffect Color="Gold" BlurRadius="5" ShadowDepth="0"/>
                    </TextBlock.Effect>
                </TextBlock>
                <TextBlock Grid.Column="1" Text="{Binding SelectedItem.Type}" HorizontalAlignment="Right" Margin="0,0,10,10" Grid.Row="3"/>
                <CheckBox IsChecked="{Binding SelectedItem.Favorite}" Visibility="{Binding SelectedIndex, Converter={StaticResource VisibilityConverter}, ElementName=listBox}"
                          Grid.Row="3" Content="置于列表顶端" Margin="10,0,0,10" Foreground="{DynamicResource ForegroundBrushKey}" Grid.Column="1"/>
            </Grid>
        </Border>
    </Grid>
</UserControl>